package contracts.oauth2.server.resource

import org.springframework.cloud.contract.spec.Contract

/**
 * rap2文档
 * http://rap2.ctsp.kedacom.com/repository/editor?id=26&mod=130&itf=599
 */

[

        Contract.make {
            description("获取登录信息")
            name("getLoginUser")
            request {

                method "POST"
                url("/resources/getLoginUser")
                headers {
                    contentType(applicationJson())
                }

                body('''
                           {
                            "accessToken": "c27a87-a365-4326-8a91-dbc2bdd84896",
                            "clientId":"rbac",
                            "clientSecret":"123456"
                           }
                ''')
            }
            response {
                status(200)
                headers { contentType(applicationJson()) }
                body '''
                        {
                          "code": "0",
                          "result": {
                            "accessToken": {
                              "access_token": "c27a87-a365-4326-8a91-dbc2bdd84896"
                            },
                            "attributes": {},
                            "resources": [],
                            "roles": [],
                            "user": {
                              "accountNonExpired": false,
                              "accountNonLocked": false,
                              "credentialsNonExpired": false,
                              "enabled": true,
                              "id": 1,
                              "username": "admin"
                            }
                          },
                          "status": 200,
                          "timestamp": 1528190958679
                        }
                   '''
            }
        }
]
